<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
	ServletContext context = pageContext.getServletContext();
	String userid = context.getAttribute("userid").toString();
	String roles = context.getAttribute("roles").toString();
%>
<div style="height:100%; width:100%;">
    <input id="userid" value="<%=userid %>" type="hidden" />
    <table style="width: 100%;">
        <tr>
            <td class="form-label" style="width: 10%;">角色:</td>
            <td>
                <input name="ddlroles" id="ddlroles">
            </td>
        </tr>
        <tr>
            <td>
                <a href="#" class="easyui-linkbutton" onclick="saveroles()">确认</a>
            </td>
        </tr>
    </table>

</div>

<script type="text/javascript">
    $(function() {
        $('#ddlroles').combobox({
            multiple: true,
            url: '<%=basePath%>/system/role/getAllRoles',
            valueField: 'roleId',
            textField: 'name'
        });
        $.parser.onComplete = function() {
            $("#ddlroles").combobox("setValues", '<%=roles%>');
        };
    });

    function saveroles() {
        var post = {
            roles: $('#ddlroles').combobox('getValues').join(',')
        };
        $.post('<%=basePath%>/system/user/saveUserRoles?userid=<%=userid%>', post, function (data) {
            $('#storedetail').dialog('close');
            userquery();
        });
    }
</script>



